#ifndef RTSP_DECODER_HPP
#define RTSP_DECODER_HPP
#include "TcpConnection.hpp"
#include "Packet.hpp"
#include "MySQLClient.hpp"
#include <iostream>
#include <string>
#include <vector>
#include <string>
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>  // 新增
#include <libavutil/samplefmt.h>       // 新增
#include <libavutil/channel_layout.h>  
#include <libavutil/opt.h>    
#include <libavutil/mathematics.h>
#include <libavutil/timestamp.h>
}
using std::cout;;
using std::endl;
using std::string;
class RtspDecoder {
public:
    public:
    explicit RtspDecoder(string url):_url(url){}
    RtspDecoder(){}
    ~RtspDecoder(){
        cout<<"~RtspDecoder = "<<this<<endl;
    }
    void stop(){
        _isContinue = false;
    }


    static pair<string,string> recvAVCodecParameters(string url);
    void sendAVpacket(TcpConnection & ptr);
    
    int read_partial_ts(TcpConnection & ptr,const string & url, double max_duration, double tail_duration);
    void run(TcpConnection & ptr,int camera_id,int channel,long start_time,long end_time);
    void sendTsAVpacket(TcpConnection & ptr);
    static pair<string,string> get_playback_decoder_parameters(const string &);
private:
    string _url;
    bool _isContinue = true;
};
#endif // RTSP_DECODER_HPP
